<%--
  Created by IntelliJ IDEA.
  User: yanqin
  Date: 2017/6/4
  Time: 14:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>ADMIN</title>
    <%@include file="common.jsp" %>
</head>
<body>
<div class="container">
    <div>
        <br/>
        <!-- Nav tabs -->
        <ul class="nav nav-tabs" role="tablist" id="myTabs">
            <li role="presentation" class="active"><a href="#adduser" aria-controls="adduser" role="tab"
                                                      data-toggle="tab">添加用户</a></li>
            <li role="presentation"><a href="#getUser" aria-controls="getUser" role="tab" data-toggle="tab">查看用户</a>
            </li>
        </ul>

        <!-- Tab panes -->
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="adduser">
                <br/>
                <div class="form-horizontal">
                    <div class="form-group">
                        <label for="userid" class="col-sm-2 control-label">用户ID</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="userid" placeholder="用户ID">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">用户名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="username" placeholder="用户名">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="password" class="col-sm-2 control-label">密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" id="password" placeholder="密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="usertype" class="col-sm-2 control-label">用户类型</label>
                        <div class="col-sm-10">
                            <select class="form-control" id="usertype">
                                <option>测试</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button class="btn btn-primary" id="addbtn">添加</button>
                        </div>
                    </div>
                </div>
            </div>
            <div role="tabpanel" class="tab-pane" id="getUser">...</div>
        </div>

    </div>
</div>
<script type="text/javascript">
    $(function () {
        $("#addbtn").click(function () {
            $("#addbtn").attr("disabled","disabled");
            var userid = $("#userid").val();
            var username = $("#username").val();
            var password = $("#password").val();
            var usertype = $("#usertype").val();
            if (isNotNull(userid) && isNotNull(username) && isNotNull(password) && isNotNull(usertype)) {
                $.ajax({
                    url: "insert",
                    type: "post",
                    data: "userid=" + userid + "&username=" + username + "&password=" + password + "&userType=" + usertype,
                    success: function (result) {
                        alert(result);
                            $("#addbtn").removeAttr("disabled");
                    }
                });
            }
        });
    });


    $('#myTabs a').click(function (e) {
        e.preventDefault()
        $(this).tab('show')
    })
</script>
</body>
</html>
